#include <Date.h>

namespace http {
    namespace date {

        std::ostream &operator<<(std::ostream &os, Seconds s) {
            return os << s.seconds;
        }
        
        Date::Date(std::string date) {
            strptime(date.c_str(), "%c", &m_tm);
            m_time = mktime(&m_tm);
        }

        std::string Date::toString(std::string format) {
            localtime_r(&m_time, &m_tm);
            char buff[128] = {0};
            strftime(buff, 128, format.c_str(), &m_tm);
            return std::string(buff);
        }

    }  // namespace date

}  // namespace http
